package appapi.dao;

import appapi.Vo.brider.SceneDevicePageVo;
import appapi.dto.bridge.CheckDeviceDto;
import appapi.dto.bridge.FaceRecordDto;
import appapi.entity.app.SelfcheckDetailEntity;
import appapi.entity.bridge.SceneDeviceEntity;
import appapi.entity.bridge.vo.CamerVo;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

/**
 * @author dhq
 * @version 1.0
 * @date 2023/9/12  9:54
 */
public interface SceneDeviceMapper {
    int deleteByPrimaryKey(@Param("id") Long id);

    int deleteBySceneId(@Param("sceneId") Long sceneId);

    int insert(SceneDeviceEntity record);

    int insertSelective(SceneDeviceEntity record);

    SceneDeviceEntity selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(SceneDeviceEntity record);

    int updateByPrimaryKey(SceneDeviceEntity record);

    List<CheckDeviceDto> selectUnBindDevice(@Param("projId") Long projId, @Param("deviceType") Integer deviceType);

    List<CheckDeviceDto> selectUnBindDoor(@Param("projId") Long projId);

    List<CheckDeviceDto> selectUnBindPark(@Param("projId") Long projId);
    List<CheckDeviceDto> selectUnBindCamera(@Param("projId") Long projId);


    List<SceneDevicePageVo> getSceneDeviceList(@Param("secId") Long secId);


    List<SceneDeviceEntity> getBySecId(Long sceId);


    List<SceneDevicePageVo> getSceneDevice(@Param("sceId") Long sceId);

    List<SceneDeviceEntity> selectSenceDeviceEntity(@Param("sceId") Long sceId);


    List<CamerVo> getSceneDevices(@Param("orgaPathIds") String orgaPathIds);

    @Select("SELECT COUNT(*) FROM scene_device s " +
            "JOIN project p ON s.proj_id = p.proj_id " +
            "JOIN organization org ON p.orga_id = org.orga_id " +
            "WHERE s.device_type IN (1, 2, 3) AND org.orga_id = #{orgaId}")
    int Tcount(@Param("orgaId") Integer orgaId);

    @Select("SELECT COUNT(*) FROM scene_device s " +
            "JOIN project p ON s.proj_id = p.proj_id " +
            "JOIN organization org ON p.orga_id = org.orga_id " +
            "WHERE s.device_type IN (4, 5, 6) AND org.orga_id = #{orgaId}")
    int Ccount(@Param("orgaId") Integer orgaId);

    List<SceneDeviceEntity> selectDataDeviceBySecId(Long sceId);

}